// 导入文件 写入路由
import Vue from 'vue'
import VueRouter from 'vue-router'
// @ 是 src 目录的别名
import Home from '../views/Home.vue'
import Person from '../views/Person.vue'
import Login from '@/views/Login.vue'
import Register from '@/views/Register.vue'
import NewsList from '@/views/NewsList.vue'
import NewsInfo from '@/views/Newslnfo.vue'
// 如果想导入某个文件夹下的index.js可以省略index.js 直接写某个目录下的文件下就行


Vue.use(VueRouter)



let routes = [
    {
        path: '/',
        redirect: '/newslist'
    },
    {
        path: '/newslist',
        // component 重定向
        component: NewsList
    },
    {
        path: '/home',
        component: Home,
        children: [
            {
                path: 'login',
                component: Login
            },
            {
                path: 'register',
                component: Register
            }
        ]
    },
    {
        path: '/person',
        component: Person
    },
    {
        path: '/newsinfo/:id/:pwd',
        name: 'NewsInfo',
        component: NewsInfo
    }
    // {
    //     path:'/newsinfo',
    //     name:'NewsInfo',
    //     component:NewsInfo
    // }
]
const router = new VueRouter({
    routes
})

export default router
